package org.jg.arkanoid.gameobjects.objectpanel;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;

import javax.swing.JPanel;

import org.jg.arkanoid.gameobjects.Brick;
import org.jg.arkanoid.util.Vector;

public class BrickPanel extends JPanel{
private static final long serialVersionUID = 1L;
	
	private Brick brick;
	
	public BrickPanel( Brick brick ){
		this.brick = brick;
	}
	
	public void paintComponent(Graphics g){
		super.paintComponent(g);
		Graphics2D g2 = (Graphics2D) g;

		setOpaque(false);
		
		Vector position = brick.getPosition();
		int width = brick.getWidth();
		int height = brick.getHeight();
		
		setBounds((int)position.getX(), (int)position.getY(), width, height);
		
		Rectangle2D rectangle = new Rectangle2D.Double(0, 0, width, height);
		g2.setPaint(brick.getColor());
		g2.fill(rectangle);
	}
}
